﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SzCourt.Logic.BLL;
using SzCourt.Logic.NBL.DBEntities;
using KMFrame.Permission.Util;

namespace SzCourt.WebSite.reporter
{
    public partial class addNews : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                if (SessionBox.CheckUserSession())
                {
                    getSessionInfo();
                }
                else
                {
                    Response.Redirect("/reporter/login.aspx");
                }
            }
        }

        private void getSessionInfo()
        {
            if (!SessionBox.CheckUserSession())
            {
                Response.Redirect("/reporter/login.aspx");
            }
            this.spUserName.InnerHtml = SessionBox.GetUserSession().UserName;
            this.spDate.InnerHtml = DateTime.Now.ToString();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int UserID = 0;
            if (SessionBox.CheckUserSession())
            {
                UserID = SessionBox.GetUserSession().UserID;
            }
            else
            {
                Response.Redirect("/reporter/login.aspx");
            }

            pReporterHomeInfo param = new pReporterHomeInfo();

            param.AddUserID = UserID;
            param.AddUserName = SessionBox.GetUserSession().UserName;
            param.Title = this.txtTitle.Value;
            param.Content = this.content.Value;
            param.InfoType = "新闻";
            ReporterHome bll = new ReporterHome();
            bool result = (bool)bll.AddInfo(param);
            if (result)
            {
                this.divMessage.InnerHtml = "添加成功！";
            }
            else
            {
                this.divMessage.InnerHtml = "添加失败！";
            }
        }
    }
}